<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateGuildAccountMonthlyTable extends Migration
{
    protected $connection = 'guild';

    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('guild_account_monthly', function (Blueprint $table) {
            $table->increments('id');
            $table->char('mon', 8)->comment('统计日期');
            $table->integer('guild_manage_id')->default(0)->comment('公会内部ID');
            $table->double('total_income', 1)->default(0.0)->comment('公会总流水');
            $table->double('voice_income', 1)->default(0.0)->comment('语音总流水');
            $table->double('video_income', 1)->default(0.0)->comment('视频总流水');
            $table->smallInteger('active_host_num')->default(0)->comment('活跃主播数量');
            $table->smallInteger('income_host_num')->default(0)->comment('收益主播数量');
            $table->double('host_share_income', 1)->default(0.0)->comment('主播分成');
            $table->double('guild_share_income', 1)->default(0.0)->comment('公会分成');
            $table->timestamps();
            $table->tinyInteger('flag')->default(1)->comment('记录状态');
            $table->index('guild_manage_id', 'guild_manage_id');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('guild_account_monthly');
    }
}
